package com.taoge.api.sms.register;

import com.taoge.biz.common.enums.SmsActionType;
import com.taoge.biz.server.VerifyCodeServer;
import com.taoge.biz.server.param.sms.SendSmsCodeParam;
import com.taoge.framework.common.ResponseData;
import com.taoge.framework.controller.BaseController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @className: com.taoge.api.sms.register
 * @description: 短信注册
 * @author: YaoSiCheng
 * @date: 2024-06-17 16:59
 **/
@RestController
public class SmsRegisterController extends BaseController<SmsRegisterParam> {

    @Resource
    VerifyCodeServer verifyCodeServer;

    /**
     * @title: execute
     * @description: 短信注册
     * @date:   2024-06-17 17:03:24
     * @author: YaoSiCheng
     * @param:  param
     * @return: ResponseData<?>
     */
    @PostMapping("api/sms/register")
    @Override
    public ResponseData<?> execute(@RequestBody SmsRegisterParam param) {

        SendSmsCodeParam sendSmsCodeParam = param.convertTo(SendSmsCodeParam.class);
        sendSmsCodeParam.setUserId(1L);
        sendSmsCodeParam.setIso("CN");
        sendSmsCodeParam.setIp("127.0.0.1");
        sendSmsCodeParam.setActionType(SmsActionType.REGISTER);

        verifyCodeServer.sendSmsCode(sendSmsCodeParam);
        return ResponseData.success();
    }
}
